<template>
  <el-dialog title="测试" :close-on-click-modal="false" :visible.sync="visible" center>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-form :model="dataForm" ref="dataForm" label-width="120px">
      <el-form-item label="查询语句">
        <code-mirror :value="dataForm.sentence" ref="codeMirrorDialog" @getCodeMirror="getCodeData"></code-mirror>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
        <el-button type="info" @click="visible = false">关 闭</el-button>
      <el-button type="primary" @click="testData">测 试</el-button>
      </span>
  </el-dialog>
</template>

<script>
    import CodeMirror from '../components/CodeMirror'   // 编辑器

    import {testData} from '@/api/cboard/cboard'

    export default {
        name: "test",
        data(){
            return {
                sourData: {},
                visible: false,
                dataForm: {
                    sentence: '',
                }
            }
        },
        components: {
            CodeMirror
        },
        methods: {
            init(data){
                this.sourData = data;
                console.log(data)
                this.visible = true
            },
            getCodeData(data) {
                this.$set(this.dataForm, 'sentence', data)
            },
            testData(){
                console.log(this.sourData.config+'111111')
                this.sourData.query = {"query":this.dataForm.sentence};
                testData(this.sourData).then(() =>{
                    this.$notify({
                        title: '成功',
                        message: '测试成功',
                        type: 'success',
                        duration: 2000
                    })
                })
            }
        }
    }
</script>

<style scoped>

</style>
